﻿////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// <copyright>Copyright 2008-2011 Andreas Huber Doenni</copyright>
// Distributed under the GNU General Public License version 2 (GPLv2).
// See accompanying file License.txt or copy at http://phuse.codeplex.com/license.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

namespace Phuse.Net.Forums
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    internal partial class SendReceiveHelper<TConnection> where TConnection : Connection
    {
        private sealed class SendContext : OperationContext
        {
            private readonly List<OutboundArticle> articles;

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////

            internal SendContext(SendReceiveContext context, IProgress<ISendReceiveProgress> progress) :
                base(context, progress)
            {
                this.articles = this.Group.Host.GetOutboundArticles(SendStatus.Outbox).ToList();
            }

            internal List<OutboundArticle> Articles
            {
                get { return this.articles; }
            }

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////

            protected sealed override long ItemOffset
            {
                get { return 0; }
            }

            protected sealed override long ItemCount
            {
                get { return this.articles.Count; }
            }

            protected sealed override ISendReceiveProgress CreateProgress(int percent)
            {
                return new SendProgress(percent);
            }
        }
    }
}
